package com.lcf.wx.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.toolkit.Db;
import com.lcf.common.utils.UserUtils;
import com.lcf.wx.dao.WxUserDao;
import com.lcf.wx.dto.WxUserDTO;
import com.lcf.wx.entity.WxUser;
import com.lcf.wx.service.WxUserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * 微信用户表(WxUser)表服务实现类
 *
 * @author makejava
 * @since 2025-05-22 10:13:24
 */
@Service("wxUserService")
public class WxUserServiceImpl extends ServiceImpl<WxUserDao, WxUser> implements WxUserService {
    @Override
    public void updateMyInfo(WxUserDTO dto) {
        long userId = UserUtils.getUserId();

        Db.lambdaUpdate(WxUser.class)
                .set(WxUser::getName, dto.getName())
                .set(StringUtils.isNotBlank(dto.getHeadUrl()), WxUser::getHeadUrl, dto.getHeadUrl())
                .eq(WxUser::getId, userId)
                .update();
    }
}

